package com.springboot.frame.starter.enums;

import lombok.Getter;

/**
 * @author liheng
 * @ClassName DecodeOpenTypeEnum
 * @Description
 * @date 2021-08-13 18:44
 */
public enum DecodeOpenTypeEnum {

    USER_INFO(0, "用户信息"),
    PHONE_NUMBER(1, "手机号码"),
    ;

    @Getter
    private String desc;


    @Getter
    private int code;


    DecodeOpenTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    /**
     * 通过code获取枚举
     *
     * @param code
     * @return
     */
    public static DecodeOpenTypeEnum fromCode(Integer code) {
        DecodeOpenTypeEnum[] resultTypes = DecodeOpenTypeEnum.values();
        for (DecodeOpenTypeEnum resultType : resultTypes) {
            if (code.equals(resultType.getCode())) {
                return resultType;
            }
        }
        return null;
    }
}
